package com.tito.common.api.query;

import com.tito.common.api.PageInfo;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 查询参数bean
 * @param <T>
 */
public class QueryParams<T>{
    /**
     * 分页组件
     */
    private PageInfo<T> page = null;

    /**
     * 字段参数构建列表
     */
    private Map<String, DefaultQueryField> params = new LinkedHashMap<String, DefaultQueryField>();


    public Map<String, DefaultQueryField> getParams() {
        return params;
    }

    public PageInfo<T> getPage()
    {
        return page;
    }

    public void setPage(PageInfo<T> page)
    {
        this.page = page;
    }

    public QueryParams() {
    }

    public void addParam(String name, Object obj, OptChar optChar) {
        this.params.put(name, new DefaultQueryField(name, optChar, obj));
    }

    public void addParam(String name, Object obj) {
        this.params.put(name, new DefaultQueryField(name, OptChar.EQUAL, obj));
    }

    public void addParams(String key, DefaultQueryField obj) {
        this.params.put(key, obj);
    }
    public void setParams(Map<String, DefaultQueryField> params) {
        this.params = params;
    }
}
